package com.wjh.spring.run;


import com.wjh.spring.bean.Student;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author wangjinhai
 * @title: SpringClient
 * @projectName spring
 * @description: TODO
 * @date 2022/3/8 14:57
 */
public class SpringClient {

	public static void main(String[] args) {

		Resource resource=new ClassPathResource("beans.xml");
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
		//读取器和工厂关联
		BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
		// 读取器和资源关联
		beanDefinitionReader.loadBeanDefinitions(resource);
		Student student = beanFactory.getBean(Student.class);
		System.out.println(student);

	}
}
